package com.itheima.exception.utils;

import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;

import java.util.Locale;

public class LocaleUtils {
    public LocaleUtils() {
    }

    public static String getMessage(String code, Object... args) {
        Locale locale = LocaleContextHolder.getLocale();
        MessageSource messageSource = (MessageSource)ApplicationContextUtils.getBean(MessageSource.class);
        return messageSource.getMessage(code, args, code, locale);
    }
}